{% assign data = section.settings %}
{% capture container %}
    {%- if data.is_fill -%}
        full_container_wrapper
    {%- else -%}
        container_wrapper
    {%- endif -%}
{% endcapture %}

{% assign blockId = block_id | default : section.block_id %}

<div class="block_logo_list">
	<div class="{{ container }} relative public_swiper_nav_button">
		<div class="swiper overflow-hidden" id="swiper-{{ blockId }}">
			<ul class="swiper-wrapper">
				{% for block in section.blocks %}
					<li class="swiper-slide">
						<a href="{{ block.href | setUrlDataFrom:data_from }}" class="inline-flex overflow-hidden">
							{% include 'lazy_img',src: block.image.src,alt: block.image.alt,class: 'w-full object-cover' %}
						</a>
					</li>
				{% endfor %}
			</ul>
		</div>
		<div class="swiper-button-prev" id="swiper-button-prev-{{ blockId }}">
			<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M 7.75 1.34375 L 6.25 2.65625 L 14.65625 12 L 6.25 21.34375 L 7.75 22.65625 L 16.75 12.65625 L 17.34375 12 L 16.75 11.34375 Z"></path></svg>
		</div>
		<div class="swiper-button-next" id="swiper-button-next-{{ blockId }}">
			<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M 7.75 1.34375 L 6.25 2.65625 L 14.65625 12 L 6.25 21.34375 L 7.75 22.65625 L 16.75 12.65625 L 17.34375 12 L 16.75 11.34375 Z"></path></svg>
		</div>
	</div>
</div>

<script>
$(function() {
	let isMobile = moi.isMobile()
	let swiper = new Swiper('#swiper-{{ blockId }}',{
		slidesPerView: isMobile ? 1 : "{{ data.pc_number }}",
		spaceBetween: 15,
		speed: 1000,
		autoHeight: true,
		navigation: {
			nextEl: '#swiper-button-next-{{ blockId }}',
			prevEl: '#swiper-button-prev-{{ blockId }}'
		}
	})

	$(`#swiper-{{blockId}} .swiper-slide`).each(function() {
        const element = this;
        const resizeObserver = new ResizeObserver(entries => {
          for (const entry of entries) {
            swiper.update()
          }
        });
        resizeObserver.observe(element);
    });
})
</script>

{% schema %}
{
	"class": "block_logo_list",
	"is_global": false,
	"icon": "icon-dantu",
	"name": {
		"zh_CN": "商标列表",
		"en_US": "List of trademarks"
	},
	"max_blocks": 20,
	"blocks": [
		{
			"name": {
				"zh_CN": "商标列表",
				"en_US": "List of trademarks"
			},
			"type": "logo_list_item",
			"settings": [
				{
					"type": "card_image",
					"label": {
						"zh_CN": "商标图片",
						"en_US": "Trademark image"
					},
					"default": {
						"src": "",
						"alt": ""
					},
					"info": {
						"zh_CN": "建议宽度400px，高度200px",
						"en_US": "Recommended width 400px, height 200px"
					},
					"id": "image"
				},
				{
					"type": "card_page_link",
					"label": {
						"zh_CN": "跳转链接",
						"en_US": "Jump links"
					},
					"default": {
						"type": "",
						"title": "",
						"url": ""
					},
					"id": "href"
				}
			]
		}
	],
	"settings": [
		{
			"type": "card_header",
			"label": {
				"zh_CN": "设置",
				"en_US": "Settings"
			}
		},
		{
			"type": "card_switch",
			"label": {
				"zh_CN": "宽度铺满",
				"en_US": "Spread the width"
			},
			"id": "is_fill",
			"default": "false"
		},
		{
			"type": "card_slider",
			"id": "pc_number",
			"max": "6",
			"min": "3",
			"label": {
				"zh_CN": "PC每排数量",
				"en_US": "PC number per row"
			},
			"default": "5"
		},
		{
			"type": "card_header",
			"label": {
				"zh_CN": "内容",
				"en_US": "Content"
			}
		}
	],
	"default": {
		"settings": {
			"is_fill": false,
			"pc_number": "5"
		},
		"blocks": [
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			},
			{
				"image": {
					"src": "",
					"alt": ""
				},
				"href": {
					"type": "",
					"title": "",
					"url": ""
				},
				"block_type": "logo_list_item"
			}
		]
	}
}
{% endschema %}